//
//  UseTimeRealTimeCell.swift
//  EasePods
//
//  Created by 李然 on 2024/5/30.
//

import UIKit

class UseTimeRealTimeCell: TableViewCell {

    override func makeUI() {
        super.makeUI()
        
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        contentView.addSubview(bgView)
        bgView.snp.makeConstraints { make in
            make.edges.equalTo(UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0))
        }
        
        let lineView = UIView()
        lineView.backgroundColor = R.color.use_time_19_text_item()
        
        bgView.addSubview(lineView)
        lineView.snp.makeConstraints { make in
            make.top.equalTo(24)
            make.leading.equalTo(20)
            make.size.equalTo(CGSize(width: 2, height: 13))
        }
        
        bgView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.centerY.equalTo(lineView)
            make.leading.equalTo(lineView.snp.trailing).offset(6)
        }
        
        bgView.addSubview(tipLabel)
        tipLabel.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(4)
            make.leading.equalTo(lineView)
            make.trailing.equalTo(-20)
        }
        
        bgView.addSubview(dataLabel)
        dataLabel.snp.makeConstraints { make in
            make.top.equalTo(tipLabel.snp.bottom).offset(16)
            make.leading.equalTo(lineView)
            make.bottom.equalTo(-20)
        }
    }
    
    func setData(_ data: Int?) {
        self.dataLabel.text = data.hourAndMinTimeFormat
    }
    
    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = R.color.use_time_18_bg_main()
        return view
    }()

    lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.textColor = R.color.use_time_19_text_item()
        label.font = Fonts.systemFont(ofSize: 14)
        label.numberOfLines = 0
        label.text = R.string.localizable.use_time_actual_time()
        return label
    }()
    
    lazy var tipLabel: UILabel = {
        let label = UILabel()
        label.textColor = R.color.use_time_20_text_item()
        label.font = Fonts.systemFont(ofSize: 12)
        label.numberOfLines = 0
        label.text = R.string.localizable.use_time_actual_time_tip()
        return label
    }()
    
    lazy var dataLabel: UILabel = {
        let label = UILabel()
        label.textColor = R.color.use_time_19_text_item()
        label.font = Fonts.mediumSystemFont(ofSize: 18)
        label.numberOfLines = 0
        return label
    }()

}
